package com.bangyo.usertype;

import java.io.Serializable;

import org.hibernate.HibernateException;
import org.hibernate.usertype.UserType;

public abstract class AbstractImmutableUserType implements UserType
{
    public Object deepCopy(Object value) throws HibernateException
    {
        return value;
    }

    public Object assemble(Serializable cached, Object owner)
        throws HibernateException
    {
        return deepCopy(cached);
    }

    public Serializable disassemble(Object value) throws HibernateException
    {
        return (Serializable)deepCopy(value);
    }

    public boolean equals(Object x, Object y) throws HibernateException
    {
        return x==y;
    }

    public int hashCode(Object x) throws HibernateException
    {
        return x.hashCode();
    }

    public Object replace(Object original, Object target, Object owner)
        throws HibernateException
    {
        return deepCopy(original);
    }

    public boolean isMutable()
    {
        return false;
    }
}
